package com.yunyi.integration.controller;

import com.yunyi.integration.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 注入类测试
 *
 * @author yunyi
 */
@RestController
@RequestMapping("test")
public class ValueInputController {

    @Value("${teacher.name}")
    private String userName;

    @Value("${likes[2]}")
    private String likeSingle;
    @Value("${dir1}")
    private String dir1;

    @Autowired
    private Environment environment;

    @Autowired
    private User user;

    @GetMapping("valueSingleInput")
    public String valueSingleInput() {
        return userName;
    }


    @GetMapping("arraySingleInput")
    public String arraySingleInput() {
        return likeSingle;
    }

    @GetMapping("commonSingleInput")
    public String commonSingleInput() {
        return dir1;
    }

    @GetMapping("environmentPropertiesGet")
    public String environmentPropertiesGet() {
        String property = environment.getProperty("teacher.name");
        return property;
    }

    @GetMapping("propertiesPropertiesGet")
    public Object propertiesPropertiesGet() {
        return user;
    }
}
